import string


class Stack(object):
    def __init__(self):
        self.items = []

    def push(self, item):
        self.items.append(item)

    def pop(self):
        return self.items.pop();

    def peek(self):
        return self.items[len(self.items) - 1]

    def isEmpty(self):
        return self.items == []

    def size(self):
        return len(self.items)


def infixToPostfix(infixexpr):
    prec = {'*': 3, "/": 3, "+": 2, "-": 2, "(": 1};  # 符号的权重

    index = 0;
    postfixList = []  # 列表
    opStack = Stack()  # 栈

    while index < len(infixexpr):
        token = infixexpr[index]  # item
        # 字母
        if token in string.ascii_uppercase or token in string.digits:
            postfixList.append(token)
        elif token == '(':
            opStack.push(token)
        elif token == ")":
            topTocken = opStack.pop();
            while topTocken != '(':
                postfixList.append(topTocken)
                topTocken = opStack.pop()
        else:
            while not opStack.isEmpty() and (prec[opStack.peek()] >= prec[token]):
                postfixList.append(opStack.pop())
            opStack.push(token)
        index += 1
    while not opStack.isEmpty():
        postfixList.append(opStack.pop())
    return ' '.join(postfixList)


str = input()
print(infixToPostfix(str))
